﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="{x:Type CheckBox}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource CheckBoxContentForegroundThemeBrush}" />
        <Setter Property="BorderBrush" Value="{x:Null}" />
        <Setter Property="Padding" Value="2,3,0,0" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid SnapsToDevicePixels="True">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="27" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Rectangle x:Name="NormalRectangle" Fill="{DynamicResource CheckBoxBackgroundThemeBrush}" Stroke="{DynamicResource CheckBoxBorderThemeBrush}" StrokeThickness="{DynamicResource CheckBoxBorderThemeThickness}"
                                       UseLayoutRounding="True" Height="21" Width="21" Margin="3,3,3,3" VerticalAlignment="Top" />
                            <Path x:Name="CheckGlyph" Data="F1 M 0,58 L 2,56 L 6,60 L 13,51 L 15,53 L 6,64 z" Fill="{DynamicResource CheckBoxForegroundThemeBrush}"
                                  Height="14" Stretch="Fill" Width="16" Opacity="0" FlowDirection="LeftToRight" Margin="0,7,0,0" VerticalAlignment="Top" />
                            <Rectangle x:Name="IndeterminateGlyph" Width="9" Height="9" Fill="{DynamicResource CheckBoxForegroundThemeBrush}" Opacity="0" Margin="0,9,0,0" VerticalAlignment="Top" />
                            <Rectangle x:Name="FocusVisualWhite" Stroke="{DynamicResource FocusVisualWhiteStrokeThemeBrush}" Opacity="0"
                                       Width="27" Height="27" VerticalAlignment="Top" />
                            <Rectangle x:Name="FocusVisualBlack" Stroke="{DynamicResource FocusVisualBlackStrokeThemeBrush}" Opacity="0"
                                       Width="27" Height="27" VerticalAlignment="Top" />
                            <ContentControl x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.Column="1" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="NormalRectangle" Property="Fill" Value="{DynamicResource CheckBoxPointerOverBackgroundThemeBrush}" />
                            <Setter TargetName="NormalRectangle" Property="Stroke" Value="{DynamicResource CheckBoxPointerOverBorderThemeBrush}" />
                            <Setter TargetName="CheckGlyph" Property="Fill" Value="{DynamicResource CheckBoxPointerOverForegroundThemeBrush}" />
                            <Setter TargetName="IndeterminateGlyph" Property="Fill" Value="{DynamicResource CheckBoxPointerOverForegroundThemeBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="NormalRectangle" Property="Fill" Value="{DynamicResource CheckBoxDisabledBackgroundThemeBrush}" />
                            <Setter TargetName="NormalRectangle" Property="Stroke" Value="{DynamicResource CheckBoxDisabledBorderThemeBrush}" />
                            <Setter TargetName="CheckGlyph" Property="Fill" Value="{DynamicResource CheckBoxDisabledForegroundThemeBrush}" />
                            <Setter TargetName="IndeterminateGlyph" Property="Fill" Value="{DynamicResource CheckBoxDisabledForegroundThemeBrush}" />
                            <Setter TargetName="ContentPresenter" Property="Foreground" Value="{DynamicResource CheckBoxContentDisabledForegroundThemeBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="NormalRectangle" Property="Fill" Value="{DynamicResource CheckBoxPressedBackgroundThemeBrush}" />
                            <Setter TargetName="NormalRectangle" Property="Stroke" Value="{DynamicResource CheckBoxPressedBorderThemeBrush}" />
                            <Setter TargetName="CheckGlyph" Property="Fill" Value="{DynamicResource CheckBoxPressedForegroundThemeBrush}" />
                            <Setter TargetName="IndeterminateGlyph" Property="Fill" Value="{DynamicResource CheckBoxPressedForegroundThemeBrush}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="CheckGlyph" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="{x:Null}">
                            <Setter TargetName="IndeterminateGlyph" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="FocusVisualWhite" Property="Opacity" Value="1" />
                            <Setter TargetName="FocusVisualBlack" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="Validation.HasError" Value="True">
                            <Setter TargetName="FocusVisualWhite" Property="Opacity" Value="1" />
                            <Setter TargetName="FocusVisualBlack" Property="Opacity" Value="1" />
                            <Setter TargetName="FocusVisualWhite" Property="Stroke" Value="{DynamicResource ControlValidationInvalidThemeBrush}" />
                            <Setter TargetName="FocusVisualBlack" Property="Stroke" Value="{DynamicResource ControlValidationInvalidThemeBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>